import React, { useEffect } from 'react';
import { TreeSelect } from 'antd';

export default function CustomeTree({ value, onChange, treeData, placeholder = '请选择' }) {
  useEffect(() => {
    onChange(value);
  }, []);
  // const handleChange = (e) => {
  //   // 自定义表单控件change事件
  //   onChange(e);
  //   // 页面自定义change事件
  //   onHandleChange?.(e);
  // };
  return (
    <TreeSelect
      allowClear
      value={value}
      onChange={(e) => onChange(e)}
      getPopupContainer={(triggerNode) => triggerNode.parentElement}
      dropdownClassName="drop-down dt-select-tree-dropdown"
      treeData={treeData}
      placeholder={placeholder}
      showSearch
      treeDefaultExpandAll
      dropdownMatchSelectWidth
      treeNodeFilterProp="label"
    />
  );
}
